using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;
using Liquid.Windows;
using Ninject;

namespace NTweet.Krypton {
	public partial class MainForm : KryptonForm, ITrayForm {
		Client client;

		public MainForm(Client client, IEnumerable<ViewListBase> viewLists) {
			this.client = client;
			InitializeComponent();
			foreach (var viewList in viewLists.OrderBy((v) => v.Order)) {
				viewList.Dock = DockStyle.Fill;
				viewListContextMenu.Items.Add(
					new ToolStripMenuItem(viewList.Text, viewList.Image, new EventHandler(viewListItem_Clicked)) {
						Tag = viewList
					}
				);
			}
			viewListItem_Clicked(viewListContextMenu.Items[0], EventArgs.Empty);
		}

		private void viewListItem_Clicked(object senderObj, EventArgs e) {
			var sender = (ToolStripMenuItem)senderObj;
			foreach (ToolStripMenuItem item in viewListContextMenu.Items) {
				item.Checked = sender == item;
			}
			var viewList = (ViewListBase)sender.Tag;
			viewListHeader.ValuesPrimary.Heading = viewList.Text;
			viewListHeader.ValuesPrimary.Image = viewList.Image;
			viewListHeader.Panel.SuspendLayout();
			viewListHeader.Panel.Controls.Clear();
			viewListHeader.Panel.Controls.Add(viewList);
			viewListHeader.Panel.ResumeLayout(true);
		}

		public TrayApplicationContext TrayApplicationContext { get; set; }

		private void toolStripButton1_Click(object sender, EventArgs e) {
			split1.Panel2Collapsed =
				!split1.Panel2Collapsed;
		}
	}
}